<?php

/**
 * Created by PhpStorm.
 * User: zl
 * Date: 2017/5/1
 * Time: 15:15
 */
    require_once ('Common.php');
    require_once ('SQLBase.php');
    require_once ('UserInfo.php');
    
    //返回结果数组
    $result_array = array();

    $user = trim($_REQUEST['user']);
    $pwd = trim($_REQUEST['pwd']);

    $u = new UserInfo();
    $result_array = $u->getBasicLoginUser($user, $pwd);
    if($result_array['state'] != 0){
        $result_array['department_info'] = $u->getDepartmentInfo($user);
        $result_array['admin_power'] = $u->getApprovePowerAdmin($user);
        $result_array['sys_admin'] = 0;
//        $r = $u->getApprovePower($user);
//        if(!$r){
//            $result_array['admin_power'] = false;
//        }
//        else{
//            $result_array['admin_power'] = $r;
//        }
        $result_array['finance_admin'] = $u->isFinanceAdmin($user);

        //$result_array['admin_power'] = $u->getApprovePower($user);
    }
    else{
       $r = $u->isSysAdmin($user, $pwd);
       if($r == 1){
           $result_array['sys_admin'] = 1;
           $result_array['state'] = 1;
           $result_array['error'] = '';
       }
       else{
           $result_array['state'] = 0;
       }
    }

    echo json_encode($result_array);

?>